"""
    Created By Khun on 2020/6/30
"""

__author__ = 'Khun'

import xadmin
from medium.models import MediumList
from utils.constants import PAGE_SIZE


class MediumAdmin(object):
    """ 开单/退款 """
    list_display = ('platform', 'created_at', 'amount', 'rebate', 'recharge', 'remark')
    list_filter = ('platform', 'created_at', 'amount')
    search_fields = ('platform', 'created_at', 'amount')
    list_per_page = PAGE_SIZE  # 分页的页数
    model_icon = 'fa fa-wechat'
    list_export = ''  # 禁止导出数据
    show_bookmarks = False  # 关闭书签功能
    reversion_enable = True
    # 可以使用聚合函数
    aggregate_fields = {'amount': 'sum', 'recharge': 'sum'}
    list_editable = ('amount', 'rebate', 'recharge')


xadmin.site.register(MediumList, MediumAdmin)
